package org.shj.xiti

import scala.collection.mutable.ArrayBuffer

//#打印出杨辉三角形

object T061 {
  def main(args: Array[String]): Unit = {
    val n = 10
    val arr = ArrayBuffer[ArrayBuffer[Int]]()
    
    for(i <- 0 to n-1){
      var tmp = ArrayBuffer[Int]()
      arr += tmp
      
      for(j <- 0 to i){
        if(j == 0 || j == i){
          tmp += 1
        }else
          tmp += arr(i-1)(j) + arr(i-1)(j-1)
      }
    }
    
    arr.foreach(item => {item.foreach(n => print( n + " ")); println})
    
  }
}